package com.gmj.controller;


import com.gmj.entity.LaboratoryHealth;
import com.gmj.entity.Repair;
import com.gmj.service.ILaboratoryHealthService;
import com.gmj.service.IRepairService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author gmj
 * @since 2022-01-29
 */
@RestController
@RequestMapping("/repair")
public class RepairController {
    @Autowired
    private IRepairService rs;
    @GetMapping("/selectAll")
    public List<Repair> selectAll(){
        return rs.list();
    }
    @PostMapping("/add")
    public void add(@RequestBody Repair repair){
        repair.setSubmitTime(LocalDateTime.now());
        repair.setState(0);
        rs.save(repair);
    }

    @DeleteMapping("/delete/{id}")
    public void delete(@PathVariable("id") int id){
        rs.removeById(id);
    }
    @PutMapping("/update/{id}")
    public void update(@PathVariable("id") int id){
        Repair repair=new Repair();
        repair.setId(id);
        repair.setState(1);
        rs.updateById(repair);
    }
}

